// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router/index'
import store from './vuex/store'
// import Vant from 'vant'
import Vant from 'vant'
import { Lazyload } from 'vant';
import VueClipboard from 'vue-clipboard2'
import VueWechatTitle from 'vue-wechat-title'
import echarts from "echarts";
Vue.prototype.$echarts = echarts;

import VCharts from 'v-charts'
Vue.use(VCharts)

require('./mock/mock.js');


// import './assets/js/rem'
import './assets/font/iconfont'

Vue.use(Vant);
Vue.use(Lazyload);
Vue.use(VueClipboard);
Vue.use(VueWechatTitle)
Vue.config.productionTip = false
window.$ = require('jquery');

import $ajax from './http'
Vue.prototype.$ajax = $ajax
import { Toast } from 'vant';

router.beforeEach((to, from, next) =>{
  // console.log('123',to);
  const ua = navigator.userAgent.toLowerCase();
  if (ua.match(/MicroMessenger/i) != "micromessenger") {
    console.log('非微信打开');
  } else {
    //在微信中打开
    console.log('在微信中打开11',to);
  }
  // if((to.name !== 'home') && !sessionStorage.getItem('access_token')) {
  //   if(to.name !== 'login') {
  //     Toast('暂未登录')
  //   }
  //   setTimeout(() => {
  //     next({
  //       name: 'login'
  //     })
  //   }, 3000);
  // }
  window.scrollTo(0, 0)
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
